| Miles Sound System SDK 7.2a |
Q: | How do I smoothly ramp up or ramp down the volume of a sample over time? |
A: | There is a special digital filter for this very purpose. To use it, you attach the filter to the sample, and then just set the time and ramp levels that you want to use. To find the filter and attach it to the HSAMPLE, you would use code like this: Once you've done this, the sample can be volume-ramped whenever you like. You set the level once with the ramp time at zero to set the starting ramp level, and then again with a non-zero ramp time to set the final level and begin the ramping. Remember to always set the ramp time first, and then the ramp level. So, to smoothly ramp the volume up from 0.0 to 1.0, use something like this: Similarly, to fade out over one second, do something like this: Note that the filter remembers the last ramp level, so you only have to set the starting ramp level if you don't already know what it is. So, if you ramp from 0.0 to 1.0, and then later want to ramp back down to 0.0, you don't need to set the initial ramp level to 1.0. |
Next Topic (How do I play a 3D digital sound?)
Previous Topic (How do I start an audio file somewhere in the middle?)
Group:
FAQs and How Tos
Related Sections:
Volume Ramp Filter
For technical support, e-mail Miles3@radgametools.com
© Copyright 1991-2007 RAD Game Tools, Inc. All Rights Reserved.